﻿using Max.PH5_2011A.DTO;
using Max.PH5_2011A.IService;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Max.PH5_2011A.API.Controllers.Product
{
    [Route("product/sku")]
    [ApiController]
    public class ProductSkuController : ControllerBase
    {

        IProductSkuService _service;

        public ProductSkuController(IProductSkuService service)
        {
            _service = service;
        }

        /// <summary>
        /// 获取SKU列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetSkuList(string? brandId="",string sortField="id",bool isAsc = true)
        {
            ResponseResultDto<IQueryable<ProductSkuOutputDto>> result = new();
            var list = _service.GetSkuList(brandId,sortField,isAsc);
            
            result.Data = list;
            return Ok(result);
        }
        /// <summary>
        /// 获取SKU详情
        /// </summary>
        /// <returns></returns>
        [HttpGet("detail")]
        public IActionResult GetSkuDetail( string skuId)
        {
            ResponseResultDto<dynamic> result = new();
            var list = _service.GetSkuDetail(skuId);
            result.Data = list;
            return Ok(result);
        }



    }
}
